package com.guigu.order.service.impl;

import com.guigu.common.request.HttpUrlUtils;
import com.guigu.order.entity.OrderLocation;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.order.mapper.OrderLocationMapper;
import com.guigu.order.service.OrderLocationService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 订单位置信息  服务实现类
 * </p>
 *
 * @author TaoLong
 * @since 2021-11-09
 */
@Service
public class OrderLocationServiceImpl extends ServiceImpl<OrderLocationMapper, OrderLocation> implements OrderLocationService {
    @Value("${ampap-ack}")
    private String secret;
    private StringBuilder url = new StringBuilder("https://restapi.amap.com/v3/distance?");

    @Override
    public Map<String, Object> getDistance(String begin, String end) {
        url.append("origins=");
        url.append(begin);
        url.append("&destination=");
        url.append(end);
        url.append("&output=json");
        url.append("&key=");
        url.append(secret);
        return HttpUrlUtils.sendUrl(url.toString());
    }


}
